'''
T=0.1 364
T=0.5 364
T=1   371
T=2   372
T=5   373
T=10  373
'''

from judge import black_list,ip_list
from pyecharts import options as opts
from pyecharts.charts import Bar,Line
from pyecharts.charts import Bar

bar=Bar()
bar.add_xaxis(['0.1','0.5','1.0','2.0','5.0','10.0'])
bar.add_yaxis('数量',[364,364,371,372,373,373])
bar.set_global_opts(title_opts=opts.TitleOpts(
            title='时间差与统计ip数量的关系'
            ))
bar.render('result1.html')

#选取T=1s下进行黑名单中ip在日志流量中出现的次数统计  选择前三十个

result=dict()
for ip in black_list:
    result[ip]=ip_list.count(ip)
listresult=sorted(result.items(),key=lambda x:x[1],reverse=True)
ips=[]
counts=[]
for line in listresult[0:30]:
    ips.append(line[0])
    counts.append(line[1])

    
bar_2=Bar()
bar_2.add_xaxis(ips)
bar_2.add_yaxis('',counts)
bar_2.set_global_opts(title_opts=opts.TitleOpts(title='可疑流量统计'))
bar_2.reversal_axis()
bar_2.render('result2.html')
